package com.service.imple.admin;

import com.dao.GoodsCatalogMapper;
import com.entity.Goods;
import com.entity.GoodsCatalog;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.service.admin.GoodsCatalogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class GoodsCatalogServiceImple implements GoodsCatalogService {

    @Autowired
    private GoodsCatalogMapper goodsCatalogMapper;

    @Override
    public List<GoodsCatalog> SelectAll(Map map) {
        return null;
    }

    @Override
    public PageInfo<GoodsCatalog> selectByPage(Map<String, Object> param) {
        int pageNum=Integer.parseInt(param.get("pageNum").toString());
        PageHelper.startPage(pageNum,6);
        List<GoodsCatalog> list = goodsCatalogMapper.SelectAll(param);
        PageInfo<GoodsCatalog> info =new PageInfo<>(list);
        return info;
    }

    @Override
    public List<GoodsCatalog> select(Map map) {
        return goodsCatalogMapper.SelectAll(map);
    }

    @Override
    public int insert(GoodsCatalog goodsCatalog) {
        return goodsCatalogMapper.insert(goodsCatalog);
    }

    @Override
    public int update(GoodsCatalog goodsCatalog) {
        return goodsCatalogMapper.updateByPrimaryKey(goodsCatalog);
    }

    @Override
    public int delete(int id) {
        return goodsCatalogMapper.deleteByPrimaryKey(id);
    }
}
